Skip to content

feat(test): use snapshots for testing - #13

Open
hydrobeam wants to merge 8 commits into
mainfrom
snapshots
Open

hydrobeam wants to merge 8 commits into
mainfrom
snapshots

Conversation

@hydrobeam

Copy link
Copy Markdown
Owner

this PR overhauls the testing system to use snapshots to verify the stability of the parser. before, a lot of these were just print statements and manually verified (i know...), so it's a pretty big improvement.

  • new insta dev dependency
  • new Parser::render_tree(): provides an indented view of the parser and includes spans. replaces print_tree()
  • snap!() macro: used in org-parser for writing tests that check against the parser tree
  • org-exporter tests use inline snapshots instead of having to manually generate the output and inserting it manually (insta inserts text into empty snaps @"")

also updated the README with testing docs since insta has some slight understanding overhead, but it's fairly straightforward imo.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview ready!

Name Link
Latest commit c90bc2e
Latest deploy log https://github.com/hydrobeam/org-rust/actions/runs/36664472346
Deploy Preview Url https://snapshots.org-rust.pages.dev

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Tree rendering is nondeterministic for map-bearing nodes, omits table captions, and one existing exporter path is removed from normal CI.

Review effort: Balanced
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Migrates parser and exporter tests to deterministic insta snapshots and documents the new workflow.

Changes:

  • Adds Parser::render_tree() and parser snapshot utilities.
  • Replaces print-based and direct exporter assertions with snapshots.
  • Adds snapshot configuration, fixtures, and contributor documentation.
File Description
.cargo/​config.toml Configures snapshot metadata formatting.
.gitignore Ignores pending snapshots.
README.org Documents snapshot workflows.
crates/​org-wasm/​src/​lib.rs Reorders parser imports.
crates/​org-parser/​Cargo.toml Adds insta.
crates/​org-parser/​src/​lib.rs Registers rendering utilities and snapshots tests.
crates/​org-parser/​src/​render.rs Implements parser-tree rendering.
crates/​org-parser/​src/​test_util.rs Adds the snap! helper.
crates/​org-parser/​src/​types.rs Removes legacy tree printing.
crates/​org-parser/​src/​node_pool.rs Removes legacy tree printing.
crates/​org-parser/​src/​object/​sup_sub.rs Snapshots superscript parsing.
crates/​org-parser/​src/​object/​org_macro.rs Snapshots macro parsing.
crates/​org-parser/​src/​object/​markup.rs Snapshots markup parsing.
crates/​org-parser/​src/​object/​link.rs Snapshots link parsing.
crates/​org-parser/​src/​object/​latex_frag.rs Snapshots LaTeX fragments.
crates/​org-parser/​src/​object/​emoji.rs Snapshots invalid emoji parsing.
crates/​org-parser/​src/​element/​table.rs Snapshots table parsing.
crates/​org-parser/​src/​element/​plain_list.rs Snapshots list parsing.
crates/​org-parser/​src/​element/​latex_env.rs Snapshots LaTeX environments.
crates/​org-parser/​src/​element/​keyword.rs Removes stale debug code.
crates/​org-parser/​src/​element/​heading.rs Snapshots heading parsing.
crates/​org-parser/​src/​element/​drawer.rs Snapshots drawer parsing.
crates/​org-parser/​src/​element/​block.rs Snapshots block parsing.
crates/​org-parser/​snapshots/​*.snap Adds 79 expected parser-tree snapshots.
crates/​org-exporter/​Cargo.toml Adds insta.
crates/​org-exporter/​src/​utils.rs Snapshots table-of-contents output.
crates/​org-exporter/​src/​org.rs Converts Org exporter tests to snapshots.
crates/​org-exporter/​src/​html.rs Converts HTML exporter tests to snapshots.
crates/​org-exporter/​src/​include.rs Applies formatting-only changes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +22 to +25
Expr::RegularLink(l) => ids.extend(l.caption),
Expr::Affiliated(Affiliated::Name(id)) => ids.extend(id),
Expr::Affiliated(Affiliated::Caption(id)) => ids.push(*id),
Expr::Affiliated(Affiliated::Attr { child_id, .. }) => ids.extend(child_id),
"",
node.start,
node.end,
node.obj,
}

#[test]
#[ignore = "known bug: org exporter emits the src block body once per line (5x here)"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants